package m.framework.test.mock;
import m.framework.cache.CacheUtil;
import m.framework.cache.MapCache;
import m.framework.enums.Gender;
import m.framework.utils.DateTime;
import m.permission.model.User;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author ming
 * @date 2014年2月18日下午2:06:26
 */
public class UserMock {
	private static Logger log = LoggerFactory.getLogger(UserMock.class);
	
	
	static{
		CacheUtil.init(new MapCache());
		User admin=newUser("admin","管理",Gender.男,new DateTime("2014-02-14"));
		
		User a=newUser("cao.cao","曹操",Gender.男,new DateTime("1954-12-22"));
		User b=newUser("dun.xiahou","夏侯惇",Gender.男,new DateTime("1975-02-12"));
		User c=newUser("liao.zhang","张辽",Gender.男,new DateTime("1980-11-12"));
		User d=newUser("jin.yu","于禁",Gender.男,new DateTime("1992-04-24"));
		User e=newUser("he.zhang","张郃",Gender.男,new DateTime("1999-01-01"));
		User f=newUser("ji.zhen","甄姬",Gender.女,new DateTime("1983-12-01"));
		User g=newUser("chunhua.zhang","张春华",Gender.女,new DateTime("1969-07-08"));
		User h=newUser("yi.wang","王异",Gender.女,new DateTime("2001-1-1"));
		
		CacheUtil.set("/User/admin",admin);
		CacheUtil.set("/User/cao.cao",a);
		CacheUtil.set("/User/dun.xiahou",b);
		CacheUtil.set("/User/liao.zhang",c);
		CacheUtil.set("/User/jin.yu",d);
		CacheUtil.set("/User/he.zhang",e);
		CacheUtil.set("/User/jin.yu",f);
		CacheUtil.set("/User/ji.zhen",g);
		CacheUtil.set("/User/ji.zhen",h);
	}
	
	
	private static User newUser(String userCode,String userName,Gender gender,DateTime birthday){
		User user=new User();
		user.setUserId("userId"+userCode);
		user.setUserCode(userCode);
		user.setUserName(userName);
		user.setBirthday(birthday);
		user.setGender(gender);
		return user;
	} 
	
	public static User getUser(String userCode){
		return (User) CacheUtil.get(User.class,userCode);
	}
	
}




